﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public void MapEKKOPF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }


        public void SaveEKKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryEKKOPF(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapEKKOPF(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertEKKOPF(dwLocal);
            }
            UpdateEKKOPF(dwLocal);
        }
        public void InsertEKKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "INSERT INTO EKKOPF(EKKMANDANT, EKKAUFKRS, EKKAUFLFD, EKKAENZL, EKKAENB, EKKAEND, EKKNEUB, EKKNEUD, EKKAUFGRP, EKKAUFART, EKKARTGR, EKKZEICH, EKKAKKRED, EKKSACHB, EKKRSTBEZ, EKKLIEFKOMP, EKKLIEFNR, EKKBADR, EKKLADR, EKKRADR, EKKKONDSL, EKKWAEHRSL, EKKPREISLST, EKKKNTRNRL, EKKKOKRS, EKKKOLFD, EKKBDAT, EKKDATV, EKKDATB, EKKANLFRLNR, EKKADRZU, EKKLO, EKKLB, EKKLP, EKKLIZENZME, EKKVERBRME, EKKME1, EKKME2, EKKME3, EKKME4, EKKME5, EKKME6, EKKME7, EKKME8, EKKME9, EKKME10, EKKWE1, EKKWE2, EKKWE3, EKKWE4, EKKWE5, EKKWE6, EKKWE7, EKKWE8, EKKWE9, EKKWE10, EKKGESSTA, EKKEINSTA, EKKBUCHKRS, EKKABLADEST, EKKATEXTSL, EKKSTKZAEHL, EKKRABART1, EKKRABPROZ1, EKKRABART2, EKKRABPROZ2, EKKRABART3, EKKRABPROZ3, EKKRABART4, EKKRABPROZ4, EKKRABART5, EKKRABPROZ5, EKKZUAB1, EKKZUABPR1, EKKZUABWE1, EKKZUABME1, EKKABRKZ1, EKKZUAB2, EKKZUABPR2, EKKZUABWE2, EKKZUABME2, EKKABRKZ2, EKKZUAB3, EKKZUABPR3, EKKZUABWE3, EKKZUABME3, EKKABRKZ3, EKKZUAB4, EKKZUABPR4, EKKZUABWE4, EKKZUABME4, EKKABRKZ4, EKKZUAB5, EKKZUABPR5, EKKZUABWE5, EKKZUABME5, EKKABRKZ5, EKKZUARTF, EKKZUABPRF, EKKZUABWEF, EKKMEEHF, EKKABRKZF, EKKZUARTV, EKKZUABPRV, EKKZUABWEV, EKKMEEHV, EKKABRKZV, EKKVERSICH, EKKEDIKZ, EKKKOMMNR, EKKEDIDAT, EKKEDIZEIT, EKKABSAUFART, EKKFILLER)"
            + " VALUES (:EKKMANDANT,:EKKAUFKRS, :EKKAUFLFD, 4, 'JANE    ', 20081126, 'JANE    ', 20081126, 'B', 'BE', '8', '              ', '               ', 'JANE    ', '      ', 'N', '00009003', ' ', ' ', ' ', 'STD ', 'RMB', '     ', '               ', '  ', '      ', 20081111, 0, 0, '        ', '    ', '01', '  ', '        ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5464000, 0, 0, 0, 0, 0, 0, 0, 0, 0, '  ', '  ', '   ', '    ', '   ', '0000', '   ', 0, '   ', 0, '   ', 0, '   ', 0, '   ', 0, '   ', 0, 0, '   ', ' ', '   ', 0, 0, '   ', ' ', '   ', 0, 0, '   ', ' ', '   ', 0, 0, '   ', ' ', '   ', 0, 0, '   ', ' ', '   ', 0, 0, '   ', ' ', '   ', 0, 0, '   ', ' ', 0, ' ', '                    ', 0, 0, '  ', '                               ')";
            or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
            or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
            or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
            Connect2Proxy(or1);
        }
        public void DeleteEKKOPF(string client, string krs, string lfd)
        {

            OracleCommand or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE EKKOPF "
            + " WHERE EKKMANDANT=:EKKMANDANT   AND EKKAUFKRS=:EKKAUFKRS  AND EKKAUFLFD=:EKKAUFLFD";
            or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = client;
            or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = krs;
            or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = lfd;
            Connect2Proxy(or1);
        }
        public void UpdateEKKOPF(DataRow dwData, int option = 1, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    #region===================
                    or1.CommandText = "UPDATE EKKOPF SET "
                        + "EKKMANDANT=:EKKMANDANT,"
                        + "EKKAUFKRS=:EKKAUFKRS,"
                        + "EKKAUFLFD=:EKKAUFLFD,"
                        + "EKKAENZL=:EKKAENZL,"
                        + "EKKAENB=:EKKAENB,"
                        + "EKKAEND=:EKKAEND,"
                        + "EKKNEUB=:EKKNEUB,"
                        + "EKKNEUD=:EKKNEUD,"
                        + "EKKAUFGRP=:EKKAUFGRP,"
                        + "EKKAUFART=:EKKAUFART,"
                        + "EKKARTGR=:EKKARTGR,"
                        + "EKKZEICH=:EKKZEICH,"
                        + "EKKAKKRED=:EKKAKKRED,"
                        + "EKKSACHB=:EKKSACHB,"
                        + "EKKRSTBEZ=:EKKRSTBEZ,"
                        + "EKKLIEFKOMP=:EKKLIEFKOMP,"
                        + "EKKLIEFNR=:EKKLIEFNR,"
                        + "EKKBADR=:EKKBADR,"
                        + "EKKLADR=:EKKLADR,"
                        + "EKKRADR=:EKKRADR,"
                        + "EKKKONDSL=:EKKKONDSL,"
                        + "EKKWAEHRSL=:EKKWAEHRSL,"
                        + "EKKPREISLST=:EKKPREISLST,"
                        + "EKKKNTRNRL=:EKKKNTRNRL,"
                        + "EKKKOKRS=:EKKKOKRS,"
                        + "EKKKOLFD=:EKKKOLFD,"
                        + "EKKBDAT=:EKKBDAT,"
                        + "EKKDATV=:EKKDATV,"
                        + "EKKDATB=:EKKDATB,"
                        + "EKKANLFRLNR=:EKKANLFRLNR,"
                        + "EKKADRZU=:EKKADRZU,"
                        + "EKKLO=:EKKLO,"
                        + "EKKLB=:EKKLB,"
                        + "EKKLP=:EKKLP,"
                        + "EKKLIZENZME=:EKKLIZENZME,"
                        + "EKKVERBRME=:EKKVERBRME,"
                        + "EKKME1=:EKKME1,"
                        + "EKKME2=:EKKME2,"
                        + "EKKME3=:EKKME3,"
                        + "EKKME4=:EKKME4,"
                        + "EKKME5=:EKKME5,"
                        + "EKKME6=:EKKME6,"
                        + "EKKME7=:EKKME7,"
                        + "EKKME8=:EKKME8,"
                        + "EKKME9=:EKKME9,"
                        + "EKKME10=:EKKME10,"
                        + "EKKWE1=:EKKWE1,"
                        + "EKKWE2=:EKKWE2,"
                        + "EKKWE3=:EKKWE3,"
                        + "EKKWE4=:EKKWE4,"
                        + "EKKWE5=:EKKWE5,"
                        + "EKKWE6=:EKKWE6,"
                        + "EKKWE7=:EKKWE7,"
                        + "EKKWE8=:EKKWE8,"
                        + "EKKWE9=:EKKWE9,"
                        + "EKKWE10=:EKKWE10,"
                        + "EKKGESSTA=:EKKGESSTA,"
                        + "EKKEINSTA=:EKKEINSTA,"
                        + "EKKBUCHKRS=:EKKBUCHKRS,"
                        + "EKKABLADEST=:EKKABLADEST,"
                        + "EKKATEXTSL=:EKKATEXTSL,"
                        + "EKKSTKZAEHL=:EKKSTKZAEHL,"
                        + "EKKRABART1=:EKKRABART1,"
                        + "EKKRABPROZ1=:EKKRABPROZ1,"
                        + "EKKRABART2=:EKKRABART2,"
                        + "EKKRABPROZ2=:EKKRABPROZ2,"
                        + "EKKRABART3=:EKKRABART3,"
                        + "EKKRABPROZ3=:EKKRABPROZ3,"
                        + "EKKRABART4=:EKKRABART4,"
                        + "EKKRABPROZ4=:EKKRABPROZ4,"
                        + "EKKRABART5=:EKKRABART5,"
                        + "EKKRABPROZ5=:EKKRABPROZ5,"
                        + "EKKZUAB1=:EKKZUAB1,"
                        + "EKKZUABPR1=:EKKZUABPR1,"
                        + "EKKZUABWE1=:EKKZUABWE1,"
                        + "EKKZUABME1=:EKKZUABME1,"
                        + "EKKABRKZ1=:EKKABRKZ1,"
                        + "EKKZUAB2=:EKKZUAB2,"
                        + "EKKZUABPR2=:EKKZUABPR2,"
                        + "EKKZUABWE2=:EKKZUABWE2,"
                        + "EKKZUABME2=:EKKZUABME2,"
                        + "EKKABRKZ2=:EKKABRKZ2,"
                        + "EKKZUAB3=:EKKZUAB3,"
                        + "EKKZUABPR3=:EKKZUABPR3,"
                        + "EKKZUABWE3=:EKKZUABWE3,"
                        + "EKKZUABME3=:EKKZUABME3,"
                        + "EKKABRKZ3=:EKKABRKZ3,"
                        + "EKKZUAB4=:EKKZUAB4,"
                        + "EKKZUABPR4=:EKKZUABPR4,"
                        + "EKKZUABWE4=:EKKZUABWE4,"
                        + "EKKZUABME4=:EKKZUABME4,"
                        + "EKKABRKZ4=:EKKABRKZ4,"
                        + "EKKZUAB5=:EKKZUAB5,"
                        + "EKKZUABPR5=:EKKZUABPR5,"
                        + "EKKZUABWE5=:EKKZUABWE5,"
                        + "EKKZUABME5=:EKKZUABME5,"
                        + "EKKABRKZ5=:EKKABRKZ5,"
                        + "EKKZUARTF=:EKKZUARTF,"
                        + "EKKZUABPRF=:EKKZUABPRF,"
                        + "EKKZUABWEF=:EKKZUABWEF,"
                        + "EKKMEEHF=:EKKMEEHF,"
                        + "EKKABRKZF=:EKKABRKZF,"
                        + "EKKZUARTV=:EKKZUARTV,"
                        + "EKKZUABPRV=:EKKZUABPRV,"
                        + "EKKZUABWEV=:EKKZUABWEV,"
                        + "EKKMEEHV=:EKKMEEHV,"
                        + "EKKABRKZV=:EKKABRKZV,"
                        + "EKKVERSICH=:EKKVERSICH,"
                        + "EKKEDIKZ=:EKKEDIKZ,"
                        + "EKKKOMMNR=:EKKKOMMNR,"
                        + "EKKEDIDAT=:EKKEDIDAT,"
                        + "EKKEDIZEIT=:EKKEDIZEIT,"
                        + "EKKABSAUFART=:EKKABSAUFART,"
                        + "EKKFILLER=:EKKFILLER "
                        + " WHERE  "
                        + "  EKKMANDANT=:EKKMANDANT AND EKKAUFKRS=:EKKAUFKRS AND EKKAUFLFD=:EKKAUFLFD ";

                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    or1.Parameters.Add("EKKAENZL", OracleType.NVarChar).Value = dwData["EKKAENZL"].ToString();
                    or1.Parameters.Add("EKKAENB", OracleType.NVarChar).Value = dwData["EKKAENB"].ToString();
                    or1.Parameters.Add("EKKAEND", OracleType.NVarChar).Value = dwData["EKKAEND"].ToString();
                    or1.Parameters.Add("EKKNEUB", OracleType.NVarChar).Value = dwData["EKKNEUB"].ToString();
                    or1.Parameters.Add("EKKNEUD", OracleType.NVarChar).Value = dwData["EKKNEUD"].ToString();
                    or1.Parameters.Add("EKKAUFGRP", OracleType.NVarChar).Value = dwData["EKKAUFGRP"].ToString();
                    or1.Parameters.Add("EKKAUFART", OracleType.NVarChar).Value = dwData["EKKAUFART"].ToString();
                    or1.Parameters.Add("EKKARTGR", OracleType.NVarChar).Value = dwData["EKKARTGR"].ToString();
                    or1.Parameters.Add("EKKZEICH", OracleType.NVarChar).Value = dwData["EKKZEICH"].ToString();
                    or1.Parameters.Add("EKKAKKRED", OracleType.NVarChar).Value = dwData["EKKAKKRED"].ToString();
                    or1.Parameters.Add("EKKSACHB", OracleType.NVarChar).Value = dwData["EKKSACHB"].ToString();
                    or1.Parameters.Add("EKKRSTBEZ", OracleType.NVarChar).Value = dwData["EKKRSTBEZ"].ToString();
                    or1.Parameters.Add("EKKLIEFKOMP", OracleType.NVarChar).Value = dwData["EKKLIEFKOMP"].ToString();
                    or1.Parameters.Add("EKKLIEFNR", OracleType.NVarChar).Value = dwData["EKKLIEFNR"].ToString();
                    or1.Parameters.Add("EKKBADR", OracleType.NVarChar).Value = dwData["EKKBADR"].ToString();
                    or1.Parameters.Add("EKKLADR", OracleType.NVarChar).Value = dwData["EKKLADR"].ToString();
                    or1.Parameters.Add("EKKRADR", OracleType.NVarChar).Value = dwData["EKKRADR"].ToString();
                    or1.Parameters.Add("EKKKONDSL", OracleType.NVarChar).Value = dwData["EKKKONDSL"].ToString();
                    or1.Parameters.Add("EKKWAEHRSL", OracleType.NVarChar).Value = dwData["EKKWAEHRSL"].ToString();
                    or1.Parameters.Add("EKKPREISLST", OracleType.NVarChar).Value = dwData["EKKPREISLST"].ToString();
                    or1.Parameters.Add("EKKKNTRNRL", OracleType.NVarChar).Value = dwData["EKKKNTRNRL"].ToString();
                    or1.Parameters.Add("EKKKOKRS", OracleType.NVarChar).Value = dwData["EKKKOKRS"].ToString();
                    or1.Parameters.Add("EKKKOLFD", OracleType.NVarChar).Value = dwData["EKKKOLFD"].ToString();
                    or1.Parameters.Add("EKKBDAT", OracleType.NVarChar).Value = dwData["EKKBDAT"].ToString();
                    or1.Parameters.Add("EKKDATV", OracleType.NVarChar).Value = dwData["EKKDATV"].ToString();
                    or1.Parameters.Add("EKKDATB", OracleType.NVarChar).Value = dwData["EKKDATB"].ToString();
                    or1.Parameters.Add("EKKANLFRLNR", OracleType.NVarChar).Value = dwData["EKKANLFRLNR"].ToString();
                    or1.Parameters.Add("EKKADRZU", OracleType.NVarChar).Value = dwData["EKKADRZU"].ToString();
                    or1.Parameters.Add("EKKLO", OracleType.NVarChar).Value = dwData["EKKLO"].ToString();
                    or1.Parameters.Add("EKKLB", OracleType.NVarChar).Value = dwData["EKKLB"].ToString();
                    or1.Parameters.Add("EKKLP", OracleType.NVarChar).Value = dwData["EKKLP"].ToString();
                    or1.Parameters.Add("EKKLIZENZME", OracleType.NVarChar).Value = dwData["EKKLIZENZME"].ToString();
                    or1.Parameters.Add("EKKVERBRME", OracleType.NVarChar).Value = dwData["EKKVERBRME"].ToString();
                    or1.Parameters.Add("EKKME1", OracleType.NVarChar).Value = dwData["EKKME1"].ToString();
                    or1.Parameters.Add("EKKME2", OracleType.NVarChar).Value = dwData["EKKME2"].ToString();
                    or1.Parameters.Add("EKKME3", OracleType.NVarChar).Value = dwData["EKKME3"].ToString();
                    or1.Parameters.Add("EKKME4", OracleType.NVarChar).Value = dwData["EKKME4"].ToString();
                    or1.Parameters.Add("EKKME5", OracleType.NVarChar).Value = dwData["EKKME5"].ToString();
                    or1.Parameters.Add("EKKME6", OracleType.NVarChar).Value = dwData["EKKME6"].ToString();
                    or1.Parameters.Add("EKKME7", OracleType.NVarChar).Value = dwData["EKKME7"].ToString();
                    or1.Parameters.Add("EKKME8", OracleType.NVarChar).Value = dwData["EKKME8"].ToString();
                    or1.Parameters.Add("EKKME9", OracleType.NVarChar).Value = dwData["EKKME9"].ToString();
                    or1.Parameters.Add("EKKME10", OracleType.NVarChar).Value = dwData["EKKME10"].ToString();
                    or1.Parameters.Add("EKKWE1", OracleType.NVarChar).Value = dwData["EKKWE1"].ToString();
                    or1.Parameters.Add("EKKWE2", OracleType.NVarChar).Value = dwData["EKKWE2"].ToString();
                    or1.Parameters.Add("EKKWE3", OracleType.NVarChar).Value = dwData["EKKWE3"].ToString();
                    or1.Parameters.Add("EKKWE4", OracleType.NVarChar).Value = dwData["EKKWE4"].ToString();
                    or1.Parameters.Add("EKKWE5", OracleType.NVarChar).Value = dwData["EKKWE5"].ToString();
                    or1.Parameters.Add("EKKWE6", OracleType.NVarChar).Value = dwData["EKKWE6"].ToString();
                    or1.Parameters.Add("EKKWE7", OracleType.NVarChar).Value = dwData["EKKWE7"].ToString();
                    or1.Parameters.Add("EKKWE8", OracleType.NVarChar).Value = dwData["EKKWE8"].ToString();
                    or1.Parameters.Add("EKKWE9", OracleType.NVarChar).Value = dwData["EKKWE9"].ToString();
                    or1.Parameters.Add("EKKWE10", OracleType.NVarChar).Value = dwData["EKKWE10"].ToString();
                    or1.Parameters.Add("EKKGESSTA", OracleType.NVarChar).Value = dwData["EKKGESSTA"].ToString();
                    or1.Parameters.Add("EKKEINSTA", OracleType.NVarChar).Value = dwData["EKKEINSTA"].ToString();
                    or1.Parameters.Add("EKKBUCHKRS", OracleType.NVarChar).Value = dwData["EKKBUCHKRS"].ToString();
                    or1.Parameters.Add("EKKABLADEST", OracleType.NVarChar).Value = dwData["EKKABLADEST"].ToString();
                    or1.Parameters.Add("EKKATEXTSL", OracleType.NVarChar).Value = dwData["EKKATEXTSL"].ToString();
                    or1.Parameters.Add("EKKSTKZAEHL", OracleType.NVarChar).Value = dwData["EKKSTKZAEHL"].ToString();
                    or1.Parameters.Add("EKKRABART1", OracleType.NVarChar).Value = dwData["EKKRABART1"].ToString();
                    or1.Parameters.Add("EKKRABPROZ1", OracleType.NVarChar).Value = dwData["EKKRABPROZ1"].ToString();
                    or1.Parameters.Add("EKKRABART2", OracleType.NVarChar).Value = dwData["EKKRABART2"].ToString();
                    or1.Parameters.Add("EKKRABPROZ2", OracleType.NVarChar).Value = dwData["EKKRABPROZ2"].ToString();
                    or1.Parameters.Add("EKKRABART3", OracleType.NVarChar).Value = dwData["EKKRABART3"].ToString();
                    or1.Parameters.Add("EKKRABPROZ3", OracleType.NVarChar).Value = dwData["EKKRABPROZ3"].ToString();
                    or1.Parameters.Add("EKKRABART4", OracleType.NVarChar).Value = dwData["EKKRABART4"].ToString();
                    or1.Parameters.Add("EKKRABPROZ4", OracleType.NVarChar).Value = dwData["EKKRABPROZ4"].ToString();
                    or1.Parameters.Add("EKKRABART5", OracleType.NVarChar).Value = dwData["EKKRABART5"].ToString();
                    or1.Parameters.Add("EKKRABPROZ5", OracleType.NVarChar).Value = dwData["EKKRABPROZ5"].ToString();
                    or1.Parameters.Add("EKKZUAB1", OracleType.NVarChar).Value = dwData["EKKZUAB1"].ToString();
                    or1.Parameters.Add("EKKZUABPR1", OracleType.NVarChar).Value = dwData["EKKZUABPR1"].ToString();
                    or1.Parameters.Add("EKKZUABWE1", OracleType.NVarChar).Value = dwData["EKKZUABWE1"].ToString();
                    or1.Parameters.Add("EKKZUABME1", OracleType.NVarChar).Value = dwData["EKKZUABME1"].ToString();
                    or1.Parameters.Add("EKKABRKZ1", OracleType.NVarChar).Value = dwData["EKKABRKZ1"].ToString();
                    or1.Parameters.Add("EKKZUAB2", OracleType.NVarChar).Value = dwData["EKKZUAB2"].ToString();
                    or1.Parameters.Add("EKKZUABPR2", OracleType.NVarChar).Value = dwData["EKKZUABPR2"].ToString();
                    or1.Parameters.Add("EKKZUABWE2", OracleType.NVarChar).Value = dwData["EKKZUABWE2"].ToString();
                    or1.Parameters.Add("EKKZUABME2", OracleType.NVarChar).Value = dwData["EKKZUABME2"].ToString();
                    or1.Parameters.Add("EKKABRKZ2", OracleType.NVarChar).Value = dwData["EKKABRKZ2"].ToString();
                    or1.Parameters.Add("EKKZUAB3", OracleType.NVarChar).Value = dwData["EKKZUAB3"].ToString();
                    or1.Parameters.Add("EKKZUABPR3", OracleType.NVarChar).Value = dwData["EKKZUABPR3"].ToString();
                    or1.Parameters.Add("EKKZUABWE3", OracleType.NVarChar).Value = dwData["EKKZUABWE3"].ToString();
                    or1.Parameters.Add("EKKZUABME3", OracleType.NVarChar).Value = dwData["EKKZUABME3"].ToString();
                    or1.Parameters.Add("EKKABRKZ3", OracleType.NVarChar).Value = dwData["EKKABRKZ3"].ToString();
                    or1.Parameters.Add("EKKZUAB4", OracleType.NVarChar).Value = dwData["EKKZUAB4"].ToString();
                    or1.Parameters.Add("EKKZUABPR4", OracleType.NVarChar).Value = dwData["EKKZUABPR4"].ToString();
                    or1.Parameters.Add("EKKZUABWE4", OracleType.NVarChar).Value = dwData["EKKZUABWE4"].ToString();
                    or1.Parameters.Add("EKKZUABME4", OracleType.NVarChar).Value = dwData["EKKZUABME4"].ToString();
                    or1.Parameters.Add("EKKABRKZ4", OracleType.NVarChar).Value = dwData["EKKABRKZ4"].ToString();
                    or1.Parameters.Add("EKKZUAB5", OracleType.NVarChar).Value = dwData["EKKZUAB5"].ToString();
                    or1.Parameters.Add("EKKZUABPR5", OracleType.NVarChar).Value = dwData["EKKZUABPR5"].ToString();
                    or1.Parameters.Add("EKKZUABWE5", OracleType.NVarChar).Value = dwData["EKKZUABWE5"].ToString();
                    or1.Parameters.Add("EKKZUABME5", OracleType.NVarChar).Value = dwData["EKKZUABME5"].ToString();
                    or1.Parameters.Add("EKKABRKZ5", OracleType.NVarChar).Value = dwData["EKKABRKZ5"].ToString();
                    or1.Parameters.Add("EKKZUARTF", OracleType.NVarChar).Value = dwData["EKKZUARTF"].ToString();
                    or1.Parameters.Add("EKKZUABPRF", OracleType.NVarChar).Value = dwData["EKKZUABPRF"].ToString();
                    or1.Parameters.Add("EKKZUABWEF", OracleType.NVarChar).Value = dwData["EKKZUABWEF"].ToString();
                    or1.Parameters.Add("EKKMEEHF", OracleType.NVarChar).Value = dwData["EKKMEEHF"].ToString();
                    or1.Parameters.Add("EKKABRKZF", OracleType.NVarChar).Value = dwData["EKKABRKZF"].ToString();
                    or1.Parameters.Add("EKKZUARTV", OracleType.NVarChar).Value = dwData["EKKZUARTV"].ToString();
                    or1.Parameters.Add("EKKZUABPRV", OracleType.NVarChar).Value = dwData["EKKZUABPRV"].ToString();
                    or1.Parameters.Add("EKKZUABWEV", OracleType.NVarChar).Value = dwData["EKKZUABWEV"].ToString();
                    or1.Parameters.Add("EKKMEEHV", OracleType.NVarChar).Value = dwData["EKKMEEHV"].ToString();
                    or1.Parameters.Add("EKKABRKZV", OracleType.NVarChar).Value = dwData["EKKABRKZV"].ToString();
                    or1.Parameters.Add("EKKVERSICH", OracleType.NVarChar).Value = dwData["EKKVERSICH"].ToString();
                    or1.Parameters.Add("EKKEDIKZ", OracleType.NVarChar).Value = dwData["EKKEDIKZ"].ToString();
                    or1.Parameters.Add("EKKKOMMNR", OracleType.NVarChar).Value = dwData["EKKKOMMNR"].ToString();
                    or1.Parameters.Add("EKKEDIDAT", OracleType.NVarChar).Value = dwData["EKKEDIDAT"].ToString();
                    or1.Parameters.Add("EKKEDIZEIT", OracleType.NVarChar).Value = dwData["EKKEDIZEIT"].ToString();
                    or1.Parameters.Add("EKKABSAUFART", OracleType.NVarChar).Value = dwData["EKKABSAUFART"].ToString();
                    or1.Parameters.Add("EKKFILLER", OracleType.NVarChar).Value = dwData["EKKFILLER"].ToString();
                    #endregion
                    break;
                case 2:
                    or1.CommandText = "UPDATE EKKOPF SET (EKKWE1,EKKME1)=(SELECT SUM(EKPWE1),SUM(EKPME1) FROM EKPOS"
                    + " WHERE EKPSA='PO' AND EKPAUFKRS=EKKAUFKRS AND EKPAUFLFD=EKKAUFLFD  AND  EKKMANDANT=:EKKMANDANT AND EKKAUFKRS=:EKKAUFKRS AND EKKAUFLFD=:EKKAUFLFD GROUP BY EKPAUFKRS,EKPAUFLFD)"
                    + " WHERE EXISTS (SELECT 1 FROM EKPOS WHERE EKPSA='PO' AND EKPAUFKRS=EKKAUFKRS AND EKPAUFLFD=EKKAUFLFD  AND  EKKMANDANT=:EKKMANDANT AND EKKAUFKRS=:EKKAUFKRS AND EKKAUFLFD=:EKKAUFLFD)"
                     ;
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    break;
                case 3:
                    or1.CommandText = "UPDATE EKKOPF SET EKKLIEFNR=:EKKLIEFNR "
                    + " WHERE EKKMANDANT=:EKKMANDANT AND EKKAUFKRS=:EKKAUFKRS AND EKKAUFLFD=:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    or1.Parameters.Add("EKKLIEFNR", OracleType.NVarChar).Value = dwData["EKKLIEFNR"].ToString();
                    break;
                case 21:
                    or1.CommandText = "UPDATE EKKOPF SET (EKKWE1,EKKWE3)= (SELECT SUM(EKPWE1),SUM(EKPWE3) FROM EKPOS "
                        + " WHERE EKPSA ='PO' AND EKPAUFKRS=:EKKAUFKRS AND EKPAUFLFD = :EKKAUFLFD)"
                        + " WHERE EKKAUFKRS = :EKKAUFKRS AND EKKAUFLFD =:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                /*UPDATE EKKOPF SET (EKKWE1,EKKWE3)= (SELECT SUM(EKPWE1),SUM(EKPWE3) FROM EKPOS 
WHERE EKPSA ='PO' AND EKPAUFKRS= 'FP' AND EKPAUFLFD = '000288')
WHERE EKKAUFKRS = 'FP' AND EKKAUFLFD = '000288'*/
            }
            Connect2Proxy(or1);
        }
        public DataSet QueryEKKOPF(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM EKKOPF WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM EKKOPF  "
                        + " WHERE EKKMANDANT=:EKKMANDANT  AND EKKAUFKRS=:EKKAUFKRS  AND EKKAUFLFD=:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM EKKOPF WHERE EKKMANDANT=:EKKMANDANT  AND EKKLIEFNR=:EKKLIEFNR";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKLIEFNR", OracleType.NVarChar).Value = dwData["EKKLIEFNR"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM EKKOPF  "
                        + " WHERE EKKMANDANT=:EKKMANDANT  AND EKKAUFKRS=:EKKAUFKRS  AND EKKAUFLFD=:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "EKKOPF";
            Return = Result;
            return Return;
        }
    }
}
